From bf68bfcf485297ecbba3dbf90efc34253c4a5327 Mon Sep 17 00:00:00 2001 From: "emellor@leeni.uk.xensource.com" Date: Tue, 13 Dec 2005 16:26:24 +0000 Subject: [PATCH] Change the way domain configuration is handled in xm-test. This will simplify the way we differentiate between HV and PV domains, as well as make it easier to run normal tests in either HV or PV mode. This patch has been modified by Ewan Mellor, to match his recent changes to remove the nics= configuration option. Signed-off-by: Dan Smith Signed-off-by: Dan Stekloff --- tools/xm-test/lib/XmTestLib/XenDomain.py | 385 ++++++++---------- .../11_block_attach_shared_dom0.py | 5 +- .../12_block_attach_shared_domU.py | 8 +- .../01_block-destroy_btblock_pos.py | 5 +- .../05_block-destroy_byname_pos.py | 5 +- .../tests/block-list/01_block-list_pos.py | 5 +- .../block-list/03_block-list_anotherbd_pos.py | 5 +- .../tests/create/01_create_basic_pos.py | 4 +- .../xm-test/tests/create/06_create_mem_neg.py | 24 +- .../tests/create/07_create_mem64_pos.py | 11 +- .../tests/create/08_create_mem128_pos.py | 11 +- .../tests/create/09_create_mem256_pos.py | 11 +- .../tests/create/11_create_concurrent_pos.py | 2 +- .../create/12_create_concurrent_stress_pos.py | 2 +- .../tests/create/13_create_multinic_pos.py | 4 +- .../tests/create/14_create_blockroot_pos.py | 27 +- .../tests/create/15_create_smallmem_pos.py | 4 +- .../tests/memset/03_memset_random_pos.py | 4 +- .../network/02_network_local_ping_pos.py | 4 +- .../tests/network/05_network_dom0_ping_pos.py | 4 +- .../tests/network/11_network_domU_ping_pos.py | 7 +- .../restore/04_restore_withdevices_pos.py | 9 +- tools/xm-test/tests/sedf/01_sedf_multi_pos.py | 2 +- .../vcpu-disable/01_vcpu-disable_basic_pos.py | 2 +- 24 files changed, 241 insertions(+), 309 deletions(-) diff --git a/tools/xm-test/lib/XmTestLib/XenDomain.py b/tools/xm-test/lib/XmTestLib/XenDomain.py index 05ad6b36dc..5838f4693e 100644 --- a/tools/xm-test/lib/XmTestLib/XenDomain.py +++ b/tools/xm-test/lib/XmTestLib/XenDomain.py @@ -30,18 +30,140 @@ from config import * BLOCK_ROOT_DEV = "hda" -def XmTestDomain(name=None, extraOpts=None, config="/dev/null"): - if ENABLE_VMX_SUPPORT: - return XmTestVmxDomain(name, extraOpts, config) +def getDeviceModel(): + """Get the path to the device model based on + the architecture reported in uname""" + arch = os.uname()[4] + if re.search("64", arch): + return "/usr/lib64/xen/bin/qemu-dm" else: - return XmTestPvDomain(name, extraOpts, config) + return "/usr/lib/xen/bin/qemu-dm" def getDefaultKernel(): + """Get the path to the default DomU kernel""" dom0Ver = commands.getoutput("uname -r"); domUVer = dom0Ver.replace("xen0", "xenU"); return "/boot/vmlinuz-" + domUVer; +def getUniqueName(): + """Get a uniqueish name for use in a domain""" + unixtime = int(time.time()) + test_name = sys.argv[0] + test_name = re.sub("\.test", "", test_name) + test_name = re.sub("[\/\.]", "", test_name) + name = "%s-%i" % (test_name, unixtime) + + return name + +def getRdPath(): + rdpath = os.environ.get("RD_PATH") + if not rdpath: + rdpath = "../../ramdisk" + rdpath = os.path.abspath(rdpath) + + return rdpath + +ParavirtDefaults = {"memory" : 64, + "vcpus" : 1, + "kernel" : getDefaultKernel(), + "root" : "/dev/ram0", + "ramdisk" : getRdPath() + "/initrd.img" + } +VmxDefaults = {"memory" : 64, + "vcpus" : 1, + "nics" : 0, + "disk" : ["file:%s/disk.img,ioemu:%s,w" % + (getRdPath(), BLOCK_ROOT_DEV)], + "kernel" : "/usr/lib/xen/boot/vmxloader", + "builder" : "vmx", + "sdl" : 0, + "vnc" : 0, + "vncviewer" : 0, + "nographic" : 1, + "serial" : "pty", + "device_model" : getDeviceModel() + } + +if ENABLE_VMX_SUPPORT: + configDefaults = VmxDefaults +else: + configDefaults = ParavirtDefaults + +class XenConfig: + """An object to help create a xen-compliant config file""" + def __init__(self): + self.defaultOpts = {} + + # These options need to be lists + self.defaultOpts["disk"] = [] + self.defaultOpts["vif"] = [] + + self.opts = self.defaultOpts + + def toString(self): + """Convert this config to a string for writing out + to a file""" + string = "# Xen configuration generated by xm-test\n" + for k, v in self.opts.items(): + if isinstance(v, int): + piece = "%s = %i" % (k, v) + elif isinstance(v, list) and v: + piece = "%s = %s" % (k, v) + elif isinstance(v, str) and v: + piece = "%s = \"%s\"" % (k, v) + else: + piece = None + + if piece: + string += "%s\n" % piece + + return string + + def write(self, filename): + """Write this config out to filename""" + output = file(filename, "w") + output.write(self.toString()) + output.close() + + def __str__(self): + """When used as a string, we represent ourself by a config + filename, which points to a temporary config that we write + out ahead of time""" + filename = "/tmp/xm-test.conf" + self.write(filename) + return filename + + def setOpt(self, name, value): + """Set an option in the config""" + if name in self.opts.keys() and isinstance(self.opts[name], list) and not isinstance(value, list): + self.opts[name] = [value] + else: + self.opts[name] = value + + def appOpt(self, name, value): + """Append a value to a list option""" + if name in self.opts.keys() and isinstance(self.opts[name], list): + self.opts[name].append(value) + + def getOpt(self, name): + """Return the value of a config option""" + if name in self.opts.keys(): + return self.opts[name] + else: + return None + + def setOpts(self, opts): + """Batch-set options from a dictionary""" + for k, v in opts.items(): + self.setOpt(k, v) + + def clearOpts(self, name=None): + """Clear one or all config options""" + if name: + self.opts[name] = self.defaultOpts[name] + else: + self.opts = self.defaultOpts class DomainError(Exception): def __init__(self, msg, extra="", errorcode=0): @@ -55,62 +177,24 @@ class DomainError(Exception): def __str__(self): return str(self.msg) -class XenDomain: - - def __init__(self, opts={}, config="/dev/null"): - """Create a domain object. Optionally take a - dictionary of 'xm' options to use""" - - self.domID = None; - self.config = config - - if not opts.has_key("name"): - raise DomainError("Missing `name' option") - if not opts.has_key("memory"): - raise DomainError("Missing `memory' option") - if not opts.has_key("kernel"): - raise DomainError("Missing `kernel' option") - self.opts = opts - - self.configVals = None - - def __buildCmdLine(self): - c = "xm create %s" % self.config +class XenDomain: - for k in self.opts.keys(): - c += " %s=%s" % (k, self.opts[k]) - - return c + def __init__(self, name=None, config=None): + """Create a domain object. + @param config: String filename of config file + """ - def getUniqueName(self): - # - # We avoid multiple duplicate names - # here because they stick around in xend - # too long - # - unixtime = int(time.time()) - test_name = sys.argv[0] - test_name = re.sub("\.test", "", test_name) - test_name = re.sub("[\/\.]", "", test_name) - name = "%s-%i" % (test_name, unixtime) + if name: + self.name = name + else: + self.name = getUniqueName() - return name + self.config = config def start(self): - if self.configVals: - self.__writeConfig("/tmp/xm-test.conf") - self.config = "/tmp/xm-test.conf" - - commandLine = self.__buildCmdLine() - - ret, output = traceCommand(commandLine); - - try: - self.domID = self.getId() - except: - self.domID = -1; + ret, output = traceCommand("xm create %s" % self.config) if ret != 0: raise DomainError("Failed to create domain", @@ -118,190 +202,79 @@ class XenDomain: errorcode=ret) def stop(self): - prog = "xm"; - cmd = " shutdown "; + prog = "xm" + cmd = " shutdown " - ret, output = traceCommand(prog + cmd + self.opts["name"]); + ret, output = traceCommand(prog + cmd + self.config.getOpt("name")) - return ret; + return ret def destroy(self): - prog = "xm"; - cmd = " destroy "; + prog = "xm" + cmd = " destroy " - ret, output = traceCommand(prog + cmd + self.opts["name"]); + ret, output = traceCommand(prog + cmd + self.config.getOpt("name")) - return ret; + return ret def getName(self): - return self.opts["name"]; + return self.name def getId(self): return domid(self.getName()); - def configSetVar(self, key, value): - if not self.configVals: - self.configVals = {} - - self.configVals[key] = value - - def configAddDisk(self, pdev, vdev, acc): - if not self.configVals: - self.configVals = {} - if not self.configVals.has_key("disk"): - self.configVals["disk"] = [] +class XmTestDomain(XenDomain): - self.configVals["disk"].append("%s,%s,%s" % (pdev,vdev,acc)) + def __init__(self, name=None, extraConfig=None, baseConfig=configDefaults): + """Create a new xm-test domain + @param name: The requested domain name + @param extraConfig: Additional configuration options + @param baseConfig: The initial configuration defaults to use + """ + config = XenConfig() + config.setOpts(baseConfig) + if extraConfig: + config.setOpts(extraConfig) - def configAddVif(self, type, mac, bridge): - if not self.configVals: - self.configVals = {} - - if not self.configVals.has_key("vif"): - self.configVals["vif"] = [] - - if mac: - self.configVals["vif"].append("%s,%s,%s" % (type,mac,bridge)) - else: - self.configVals["vif"].append("%s,%s" % (type,bridge)) + if name: + config.setOpt("name", name) + elif not config.getOpt("name"): + config.setOpt("name", getUniqueName()) - def __writeConfig(self, configFileName): - - conf = file(configFileName, "w") - - for k,v in self.configVals.items(): - print >>conf, "%s = %s" % (k, v) - - conf.close() - -class XmTestVmxDomain(XenDomain): - - def __prepareBlockRoot(self, rdpath): - image = os.path.abspath(rdpath + "/disk.img") - self.configAddDisk("file:%s" % image, "ioemu:%s" % BLOCK_ROOT_DEV, "w") - - def __prepareVif(self): - self.configAddVif("type=ioemu", None, "bridge=xenbr0") - - def __prepareDeviceModel(self): - arch = os.uname()[4] - if re.search('64', arch): - self.configSetVar("device_model", "\"/usr/lib64/xen/bin/qemu-dm\"") - else: - self.configSetVar("device_model", "\"/usr/lib/xen/bin/qemu-dm\"") - - def __init__(self, name=None, extraOpts=None, config="/dev/null"): - - rdpath = os.environ.get("RD_PATH") - if not rdpath: - rdpath = "../../ramdisk" - - self.opts = {} - self.configVals = {} - - # Defaults - self.defaults = {"memory" : 64, - "vcpus" : 1, - "kernel" : "/usr/lib/xen/boot/vmxloader", - "builder" : "\'vmx\'", - "name" : name or self.getUniqueName() - } - - self.domID = None; - self.config = config; - - self.__prepareBlockRoot(rdpath) - #self.__prepareVif() - self.__prepareDeviceModel() - #self.configSetVar("boot","\'c\'") - self.configSetVar("sdl","0") - self.configSetVar("vnc","0") - self.configSetVar("vncviewer","0") - self.configSetVar("nographic","1") - self.configSetVar("serial","\'pty\'") - - # Copy over defaults - for key in self.defaults.keys(): - self.opts[key] = self.defaults[key] - - # Merge in extra options - if extraOpts: - for key in extraOpts.keys(): - self.opts[key] = extraOpts[key] + XenDomain.__init__(self, config.getOpt("name"), config=config) def start(self): - """We know how about how long everyone will need to wait - for our disk image to come up, so we do it here as a convenience""" - -# for i in range(0,5): -# status, output = traceCommand("xm list") - XenDomain.start(self) - waitForBoot() + if ENABLE_VMX_SUPPORT: + waitForBoot() def startNow(self): XenDomain.start(self) - def getMem(self): - return int(self.opts["memory"]) - def minSafeMem(self): return 16 -class XmTestPvDomain(XenDomain): - - def __init__(self, name=None, extraOpts=None, config="/dev/null"): - - rdpath = os.environ.get("RD_PATH") - if not rdpath: - rdpath = "../../ramdisk" - - self.opts = {} - self.configVals = None - - # Defaults - self.defaults = {"memory" : 64, - "vcpus" : 1, - "kernel" : getDefaultKernel(), - "root" : "/dev/ram0", - "name" : name or self.getUniqueName(), - "ramdisk" : rdpath + "/initrd.img" - } - - self.domID = None; - self.config = config; - - # Copy over defaults - for key in self.defaults.keys(): - self.opts[key] = self.defaults[key] - - # Merge in extra options - if extraOpts: - for key in extraOpts.keys(): - self.opts[key] = extraOpts[key] - - def start(self): - """We know how about how long everyone will need to wait - for our ramdisk to come up, so we do it here as a convenience""" +if __name__ == "__main__": -# for i in range(0,5): -# status, output = traceCommand("xm list") + c = XenConfig() - XenDomain.start(self) -# waitForBoot() + c.setOpt("foo", "bar") + c.setOpt("foob", 1) + opts = {"opt1" : 19, + "opt2" : "blah"} + c.setOpts(opts) - def startNow(self): - XenDomain.start(self) + c.setOpt("disk", "phy:/dev/ram0,hda1,w") + c.appOpt("disk", "phy:/dev/ram1,hdb1,w") - def getMem(self): - return int(self.opts["memory"]) + print str(c) - def minSafeMem(self): - return 16 + -if __name__ == "__main__": +# c.write("/tmp/foo.conf") - d = XmTestDomain(); +# d = XmTestDomain(); +# +# d.start(); - d.start(); diff --git a/tools/xm-test/tests/block-create/11_block_attach_shared_dom0.py b/tools/xm-test/tests/block-create/11_block_attach_shared_dom0.py index 01b3a794d0..4f897c3ead 100644 --- a/tools/xm-test/tests/block-create/11_block_attach_shared_dom0.py +++ b/tools/xm-test/tests/block-create/11_block_attach_shared_dom0.py @@ -21,8 +21,9 @@ if s != 0: # Now try to start a DomU with write access to /dev/ram0 -domain = XmTestDomain(); -domain.configAddDisk("phy:/dev/ram0", "hda1", "w") +config = {"disk":"phy:/dev/ram0,hda1,w"} + +domain = XmTestDomain(extraConfig=config); try: domain.start() diff --git a/tools/xm-test/tests/block-create/12_block_attach_shared_domU.py b/tools/xm-test/tests/block-create/12_block_attach_shared_domU.py index 6fba0b1f3d..c93077fb4e 100644 --- a/tools/xm-test/tests/block-create/12_block_attach_shared_domU.py +++ b/tools/xm-test/tests/block-create/12_block_attach_shared_domU.py @@ -5,11 +5,11 @@ from XmTestLib import * -dom1 = XmTestDomain() -dom2 = XmTestDomain(dom1.getName() + "-2") +config = {"disk":"phy:/dev/ram0,hda1,w"} -dom1.configAddDisk("phy:/dev/ram0", "hda1", "w") -dom2.configAddDisk("phy:/dev/ram0", "hda1", "w") +dom1 = XmTestDomain(extraConfig=config) +dom2 = XmTestDomain(dom1.getName() + "-2", + extraConfig=config) try: dom1.start() diff --git a/tools/xm-test/tests/block-destroy/01_block-destroy_btblock_pos.py b/tools/xm-test/tests/block-destroy/01_block-destroy_btblock_pos.py index 42d6ba3eaa..aa456cbdf2 100644 --- a/tools/xm-test/tests/block-destroy/01_block-destroy_btblock_pos.py +++ b/tools/xm-test/tests/block-destroy/01_block-destroy_btblock_pos.py @@ -5,9 +5,8 @@ from XmTestLib import * -domain = XmTestDomain() - -domain.configAddDisk("phy:/dev/ram0", "hda1", "w") +config = {"disk":"phy:/dev/ram0,hda1,w"} +domain = XmTestDomain(extraConfig=config) try: domain.start() diff --git a/tools/xm-test/tests/block-destroy/05_block-destroy_byname_pos.py b/tools/xm-test/tests/block-destroy/05_block-destroy_byname_pos.py index 8c95fd3b37..78e84af1e7 100644 --- a/tools/xm-test/tests/block-destroy/05_block-destroy_byname_pos.py +++ b/tools/xm-test/tests/block-destroy/05_block-destroy_byname_pos.py @@ -5,9 +5,8 @@ from XmTestLib import * -domain = XmTestDomain() - -domain.configAddDisk("phy:/dev/ram0", "hda1", "w") +config = {"disk":"phy:/dev/ram0,hda1,w"} +domain = XmTestDomain(extraConfig=config) try: domain.start() diff --git a/tools/xm-test/tests/block-list/01_block-list_pos.py b/tools/xm-test/tests/block-list/01_block-list_pos.py index ec29719140..dbe7415547 100644 --- a/tools/xm-test/tests/block-list/01_block-list_pos.py +++ b/tools/xm-test/tests/block-list/01_block-list_pos.py @@ -8,9 +8,8 @@ from XmTestLib import * -domain = XmTestDomain() - -domain.configAddDisk("phy:/dev/ram0", "hda1", "w") +config = {"disk":"phy:/dev/ram0,hda1,w"} +domain = XmTestDomain(extraConfig=config) try: domain.start() diff --git a/tools/xm-test/tests/block-list/03_block-list_anotherbd_pos.py b/tools/xm-test/tests/block-list/03_block-list_anotherbd_pos.py index b7f10e9dc2..442dd90113 100644 --- a/tools/xm-test/tests/block-list/03_block-list_anotherbd_pos.py +++ b/tools/xm-test/tests/block-list/03_block-list_anotherbd_pos.py @@ -8,9 +8,8 @@ from XmTestLib import * -domain = XmTestDomain() - -domain.configAddDisk("phy:/dev/ram0", "hda1", "w") +config = {"disk":"phy:/dev/ram0,hda1,w"} +domain = XmTestDomain(extraConfig=config) try: domain.start() diff --git a/tools/xm-test/tests/create/01_create_basic_pos.py b/tools/xm-test/tests/create/01_create_basic_pos.py index 4ce79f2505..7a45df2de4 100644 --- a/tools/xm-test/tests/create/01_create_basic_pos.py +++ b/tools/xm-test/tests/create/01_create_basic_pos.py @@ -12,9 +12,9 @@ from XmTestLib import * # Create a domain (default XmTestDomain, with our ramdisk) domain = XmTestDomain() -if int(getInfo("free_memory")) < domain.getMem(): +if int(getInfo("free_memory")) < domain.config.getOpt("memory"): SKIP("This test needs %i MB of free memory (%i MB avail)" % - (domain.getMem(), int(getInfo("free_memory")))) + (domain.config.getOpt("memory"), int(getInfo("free_memory")))) # Start it try: diff --git a/tools/xm-test/tests/create/06_create_mem_neg.py b/tools/xm-test/tests/create/06_create_mem_neg.py index 187495caa0..6f7193636b 100644 --- a/tools/xm-test/tests/create/06_create_mem_neg.py +++ b/tools/xm-test/tests/create/06_create_mem_neg.py @@ -19,15 +19,8 @@ if not rdpath: rdpath = "../ramdisk" # Test 1: create a domain with mem=0 -opts1 = { - "name" : "default", - "memory" : 0, - "kernel" : getDefaultKernel(), - "root" : "/dev/ram0", - "ramdisk" : rdpath + "/initrd.img", - } - -domain1=XenDomain(opts1) +config1 = {"memory": 0} +domain1=XmTestDomain(extraConfig=config1) try: domain1.start() @@ -43,17 +36,10 @@ if eyecatcher1 != "Fail": # Test 2: create a domain with mem>sys_mem mem = int(getInfo("total_memory")) -extreme_mem = str(mem + 100) - -opts2= { - "name" : "default", - "memory" : extreme_mem, - "kernel" : getDefaultKernel(), - "root" : "/dev/ram0", - "ramdisk" : rdpath + "/initrd.img", - } +extreme_mem = mem + 100 -domain2=XenDomain(opts2) +config2 = {"memory": extreme_mem} +domain2=XmTestDomain(extraConfig=config2) try: domain2.start() diff --git a/tools/xm-test/tests/create/07_create_mem64_pos.py b/tools/xm-test/tests/create/07_create_mem64_pos.py index 387291d870..d801b8a8b0 100644 --- a/tools/xm-test/tests/create/07_create_mem64_pos.py +++ b/tools/xm-test/tests/create/07_create_mem64_pos.py @@ -23,15 +23,8 @@ if mem < 64: SKIP("This test needs 64 MB of free memory (%i MB avail)" % mem) #create a domain with mem=64 -opts = { - "name" : "MEM64", - "memory" : 64, - "kernel" : getDefaultKernel(), - "root" : "/dev/ram0", - "ramdisk" : rdpath + "/initrd.img", - } - -domain_mem64=XenDomain(opts) +config = {"memory": 64} +domain_mem64=XmTestDomain(extraConfig=config) #start it try: diff --git a/tools/xm-test/tests/create/08_create_mem128_pos.py b/tools/xm-test/tests/create/08_create_mem128_pos.py index 643073ea17..a830c7dc8e 100644 --- a/tools/xm-test/tests/create/08_create_mem128_pos.py +++ b/tools/xm-test/tests/create/08_create_mem128_pos.py @@ -23,15 +23,8 @@ if mem < 128: SKIP("This test needs 128 MB of free memory (%i MB avail)" % mem) #create a domain with mem=128 -opts = { - "name" : "MEM128", - "memory" : 128, - "kernel" : getDefaultKernel(), - "root" : "/dev/ram0", - "ramdisk" : rdpath + "/initrd.img", - } - -domain_mem128=XenDomain(opts) +config={"memory": 128} +domain_mem128=XmTestDomain(extraConfig=config) #start it try: diff --git a/tools/xm-test/tests/create/09_create_mem256_pos.py b/tools/xm-test/tests/create/09_create_mem256_pos.py index afe13926a9..07d73d8127 100644 --- a/tools/xm-test/tests/create/09_create_mem256_pos.py +++ b/tools/xm-test/tests/create/09_create_mem256_pos.py @@ -23,15 +23,8 @@ if mem < 256: SKIP("This test needs 256 MB of free memory (%i MB avail)" % mem) #create a domain with mem=256 -opts = { - "name" : "MEM256", - "memory" : 256, - "kernel" : getDefaultKernel(), - "root" : "/dev/ram0", - "ramdisk" : rdpath + "/initrd.img", - } - -domain_mem256=XenDomain(opts) +config = {"memory": 256} +domain_mem256=XmTestDomain(extraConfig=config) #start it try: diff --git a/tools/xm-test/tests/create/11_create_concurrent_pos.py b/tools/xm-test/tests/create/11_create_concurrent_pos.py index 5dd473d0dc..d850642e45 100644 --- a/tools/xm-test/tests/create/11_create_concurrent_pos.py +++ b/tools/xm-test/tests/create/11_create_concurrent_pos.py @@ -34,7 +34,7 @@ if verbose: for d in range(0, NUM_DOMS): dom = XmTestDomain(name="11_create_%i" % d, - extraOpts={"memory":str(MEM_PER_DOM)}) + extraConfig={"memory":MEM_PER_DOM}) try: dom.start() diff --git a/tools/xm-test/tests/create/12_create_concurrent_stress_pos.py b/tools/xm-test/tests/create/12_create_concurrent_stress_pos.py index e4e925d742..8bffb1b2c6 100644 --- a/tools/xm-test/tests/create/12_create_concurrent_stress_pos.py +++ b/tools/xm-test/tests/create/12_create_concurrent_stress_pos.py @@ -14,7 +14,7 @@ DUR=60 domains = [] for i in range(0,DOMS): - dom = XmTestDomain(extraOpts={"memory" : str(MEM)}) + dom = XmTestDomain(extraConfig={"memory" : MEM}) try: dom.start() diff --git a/tools/xm-test/tests/create/13_create_multinic_pos.py b/tools/xm-test/tests/create/13_create_multinic_pos.py index 0c5c659469..eda2e2f8f7 100644 --- a/tools/xm-test/tests/create/13_create_multinic_pos.py +++ b/tools/xm-test/tests/create/13_create_multinic_pos.py @@ -6,8 +6,8 @@ from XmTestLib import * for i in range(0,10): - domain = XmTestDomain() - domain.configSetVar('vif', str(['' for _ in range(0, i)])) + config = {"vif": ['' for _ in range(0, i)]} + domain = XmTestDomain(extraConfig=config) try: domain.start() diff --git a/tools/xm-test/tests/create/14_create_blockroot_pos.py b/tools/xm-test/tests/create/14_create_blockroot_pos.py index 5f583f2a9f..c80a92ca8c 100644 --- a/tools/xm-test/tests/create/14_create_blockroot_pos.py +++ b/tools/xm-test/tests/create/14_create_blockroot_pos.py @@ -6,10 +6,9 @@ from XmTestLib import * import os +import time -CONF_FILE = "/tmp/14_create_blockroot_pos.conf" - -rdpath = os.path.abspath(os.environ.get("RD_PATH")) +rdpath = getRdPath() # status, output = traceCommand("losetup -f %s" % rdpath) # if status != 0: @@ -17,22 +16,26 @@ rdpath = os.path.abspath(os.environ.get("RD_PATH")) # # if verbose: # print "Using %s" % output - -opts = {"memory" : "64", - "root" : "/dev/hda1", - "name" : "14_create_blockroot", - "kernel" : getDefaultKernel() } - -domain = XenDomain(opts=opts) -domain.configAddDisk("file:%s/initrd.img" % rdpath, "hda1", "w") +if ENABLE_VMX_SUPPORT: + domain = XmTestDomain(name="14_create_blockroot") +else: + config = {"memory" : "64", + "root" : "/dev/hda1", + "name" : "14_create_blockroot", + "kernel" : getDefaultKernel(), + "disk" : "file:%s/initrd.img,hda1,w" % rdpath + } + domConfig = XenConfig() + domConfig.setOpts(config) + domain = XenDomain(name=domConfig.getOpt("name"), config=domConfig) try: domain.start() except DomainError, e: FAIL(str(e)) -waitForBoot() +#waitForBoot() try: console = XmConsole(domain.getName(), historySaveCmds=True) diff --git a/tools/xm-test/tests/create/15_create_smallmem_pos.py b/tools/xm-test/tests/create/15_create_smallmem_pos.py index b1ec678180..ed8c24d4ef 100644 --- a/tools/xm-test/tests/create/15_create_smallmem_pos.py +++ b/tools/xm-test/tests/create/15_create_smallmem_pos.py @@ -7,8 +7,8 @@ from XmTestLib import * MEM = 16 -domain = XmTestDomain(extraOpts={"memory":"%i" % MEM, - "extra" :"mem=%iM" % MEM}) +domain = XmTestDomain(extraConfig={"memory": MEM, + "extra" :"mem=%iM" % MEM}) try: domain.start() diff --git a/tools/xm-test/tests/memset/03_memset_random_pos.py b/tools/xm-test/tests/memset/03_memset_random_pos.py index 94cf8f9730..1f5c033710 100644 --- a/tools/xm-test/tests/memset/03_memset_random_pos.py +++ b/tools/xm-test/tests/memset/03_memset_random_pos.py @@ -20,8 +20,8 @@ except DomainError, e: FAIL(str(e)) times = random.randint(10,50) -origmem = domain.getMem() -currmem = domain.getMem() +origmem = domain.config.getOpt("memory") +currmem = domain.config.getOpt("memory") try: console = XmConsole(domain.getName()) diff --git a/tools/xm-test/tests/network/02_network_local_ping_pos.py b/tools/xm-test/tests/network/02_network_local_ping_pos.py index 510711ae23..fc1dd9abe1 100644 --- a/tools/xm-test/tests/network/02_network_local_ping_pos.py +++ b/tools/xm-test/tests/network/02_network_local_ping_pos.py @@ -28,9 +28,9 @@ ip = Net.ip("dom1", "eth0") mask = Net.mask("dom1", "eth0") # Fire up a guest domain w/1 nic -domain = XmTestDomain() +config = {"vif" : ['ip=%s' % ip]} +domain = XmTestDomain(extraConfig=config) try: - domain.configSetVar('vif', " [ 'ip=" + ip + "' ]") domain.start() except DomainError, e: if verbose: diff --git a/tools/xm-test/tests/network/05_network_dom0_ping_pos.py b/tools/xm-test/tests/network/05_network_dom0_ping_pos.py index 84e6be058a..0d218ca0bc 100644 --- a/tools/xm-test/tests/network/05_network_dom0_ping_pos.py +++ b/tools/xm-test/tests/network/05_network_dom0_ping_pos.py @@ -31,9 +31,9 @@ except NetworkError, e: FAIL(str(e)) # Fire up a guest domain w/1 nic -domain = XmTestDomain() +config = {"vif" : ["ip=%s" % ip]} +domain = XmTestDomain(extraConfig=config) try: - domain.configSetVar('vif', " [ 'ip=" + ip + "' ]") domain.start() except DomainError, e: if verbose: diff --git a/tools/xm-test/tests/network/11_network_domU_ping_pos.py b/tools/xm-test/tests/network/11_network_domU_ping_pos.py index 5ac8021562..5630ff1738 100644 --- a/tools/xm-test/tests/network/11_network_domU_ping_pos.py +++ b/tools/xm-test/tests/network/11_network_domU_ping_pos.py @@ -15,15 +15,12 @@ pingsizes = [ 1, 48, 64, 512, 1440, 1500, 1505, 4096, 4192, 32767, 65507 ] - - from XmTestLib import * - def netDomain(ip): - dom = XmTestDomain() + config = {"vif" : ["ip=%s" % ip]} + domain = XmTestDomain(extraConfig=config) try: - dom.configSetVar('vif', " [ 'ip=" + ip + "' ]") dom.start() except DomainError, e: if verbose: diff --git a/tools/xm-test/tests/restore/04_restore_withdevices_pos.py b/tools/xm-test/tests/restore/04_restore_withdevices_pos.py index af290f4b8b..61e0b3ed81 100644 --- a/tools/xm-test/tests/restore/04_restore_withdevices_pos.py +++ b/tools/xm-test/tests/restore/04_restore_withdevices_pos.py @@ -7,12 +7,9 @@ from XmTestLib import * import re -domain = XmTestDomain() - -domain.configSetVar('vif', "[ '', '' ]") - -domain.configAddDisk("phy:/dev/ram0", "hda1", "w") -domain.configAddDisk("phy:/dev/ram1", "hdb2", "w") +config = {"disk": ["phy:/dev/ram0,hda1,w", "phy:/dev/ram1,hdb2,w"], + "vif": ['', '']} +domain = XmTestDomain(extraConfig=config) s, o = traceCommand("mke2fs -q /dev/ram0") if s != 0: diff --git a/tools/xm-test/tests/sedf/01_sedf_multi_pos.py b/tools/xm-test/tests/sedf/01_sedf_multi_pos.py index b44fb46542..0ec057ded5 100644 --- a/tools/xm-test/tests/sedf/01_sedf_multi_pos.py +++ b/tools/xm-test/tests/sedf/01_sedf_multi_pos.py @@ -7,7 +7,7 @@ from XmTestLib import * sedf_opts = "20000000 5000000 0 0 0" -domain = XmTestDomain(extraOpts = {"sched":"sedf"}) +domain = XmTestDomain(extraConfig = {"sched":"sedf"}) try: domain.start() diff --git a/tools/xm-test/tests/vcpu-disable/01_vcpu-disable_basic_pos.py b/tools/xm-test/tests/vcpu-disable/01_vcpu-disable_basic_pos.py index cabf8dfed7..4c15735bab 100644 --- a/tools/xm-test/tests/vcpu-disable/01_vcpu-disable_basic_pos.py +++ b/tools/xm-test/tests/vcpu-disable/01_vcpu-disable_basic_pos.py @@ -39,7 +39,7 @@ if smpConcurrencyLevel() <= 1: SKIP("Host not capable of running test") # Start a XmTestDomain with 2 VCPUs -domain = XmTestDomain(extraOpts = {"vcpus":"2"}) +domain = XmTestDomain(extraConfig={"vcpus":2}) try: domain.start() -- 2.30.2